home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / bitvec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.5 KB  |  116 lines

  1. /*
  2.  *   $RCSfile: bitvec.h,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:07 $      
  5.  */ 
  6. #ifndef __BITVEC_H__
  7. #define __BITVEC_H__
  8.  
  9. /**********************************************************************
  10. * EXODUS Database Toolkit Software
  11. * Copyright (c) 1991 Computer Sciences Department, University of
  12. *                    Wisconsin -- Madison
  13. * All Rights Reserved.
  14. *
  15. * Permission to use, copy, modify and distribute this software and its
  16. * documentation is hereby granted, provided that both the copyright
  17. * notice and this permission notice appear in all copies of the
  18. * software, derivative works or modified versions, and any portions
  19. * thereof, and that both notices appear in supporting documentation.
  20. *
  21. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  22. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  23. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  24. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  25. *
  26. * The EXODUS Project Group requests users of this software to return 
  27. * any improvements or extensions that they make to:
  28. *
  29. *   EXODUS Project Group 
  30. *     c/o David J. DeWitt and Michael J. Carey
  31. *   Computer Sciences Department
  32. *   University of Wisconsin -- Madison
  33. *   Madison, WI 53706
  34. *
  35. *     or exodus@cs.wisc.edu
  36. *
  37. * In addition, the EXODUS Project Group requests that users grant the 
  38. * Computer Sciences Department rights to redistribute these changes.
  39. **********************************************************************/
  40. /*
  41.  *    define operations on bit vectors, specifically for use
  42.  *    with the select bit map
  43.  */
  44. #define BS         5 
  45. #define BO      31
  46. #define BVL     4
  47. #define MAXBITS (BVL * (1 << BS))
  48.  
  49.  
  50. /*
  51.  *    to be used for all bit vectors
  52.  */
  53. typedef struct {
  54.  
  55.         unsigned long    bv_data[BVL];
  56.  
  57. } BITVEC;
  58.  
  59.  
  60. /*
  61.  *    define the operations on the bit vectors
  62.  */
  63. #define bis(vec, b)      ((vec)->bv_data[(b) >> BS] |= 1 << ((b) & BO))
  64. #define bic(vec, b)      ((vec)->bv_data[(b) >> BS] &= ~(1 << ((b) & BO)))
  65. #define bit(vec, b)      ((vec)->bv_data[(b) >> BS] & (1 << ((b) & BO)))
  66.  
  67.  
  68. #define bisv(vec, bv)    {                                              \
  69.             (vec)->bv_data[0] |= (bv)->bv_data[0];                      \
  70.             (vec)->bv_data[1] |= (bv)->bv_data[1];                      \
  71.             (vec)->bv_data[2] |= (bv)->bv_data[2];                      \
  72.             (vec)->bv_data[3] |= (bv)->bv_data[3];                      \
  73. }
  74.  
  75. #define bandv(vec, bv)   {                                              \
  76.             (vec)->bv_data[0] &= (bv)->bv_data[0];                      \
  77.             (vec)->bv_data[1] &= (bv)->bv_data[1];                      \
  78.             (vec)->bv_data[2] &= (bv)->bv_data[2];                      \
  79.             (vec)->bv_data[3] &= (bv)->bv_data[3];                      \
  80. }
  81.  
  82. #define bicv(vec, bv)    {                                              \
  83.             (vec)->bv_data[0] &= ~(bv)->bv_data[0];                     \
  84.             (vec)->bv_data[1] &= ~(bv)->bv_data[1];                     \
  85.             (vec)->bv_data[2] &= ~(bv)->bv_data[2];                     \
  86.             (vec)->bv_data[3] &= ~(bv)->bv_data[3];                     \
  87. }
  88.  
  89. #define bisv2(vec, bv1, bv2)    {                                       \
  90.             (vec)->bv_data[0] = (bv1)->bv_data[0] | (bv2)->bv_data[0];  \
  91.             (vec)->bv_data[1] = (bv1)->bv_data[1] | (bv2)->bv_data[1];  \
  92.             (vec)->bv_data[2] = (bv1)->bv_data[2] | (bv2)->bv_data[2];  \
  93.             (vec)->bv_data[3] = (bv1)->bv_data[3] | (bv2)->bv_data[3];  \
  94. }
  95.  
  96. #define bitcom(vec, bv1, bv2)    {                                       \
  97.             (vec)->bv_data[0] = ((bv1)->bv_data[0] & (bv2)->bv_data[0]);  \
  98.             (vec)->bv_data[1] = ((bv1)->bv_data[1] & (bv2)->bv_data[1]);  \
  99.             (vec)->bv_data[2] = ((bv1)->bv_data[2] & (bv2)->bv_data[2]);  \
  100.             (vec)->bv_data[3] = ((bv1)->bv_data[3] & (bv2)->bv_data[3]);  \
  101. }
  102.  
  103. #define btest(vec)                                                         \
  104.     ((vec)->bv_data[0] || (vec)->bv_data[1] || (vec)->bv_data[2] || (vec)->bv_data[3])
  105.  
  106. #define bitv(vec, bv)    (                                              \
  107.            ((vec)->bv_data[0] & (bv)->bv_data[0]) ||                    \
  108.            ((vec)->bv_data[1] & (bv)->bv_data[1]) ||                    \
  109.            ((vec)->bv_data[2] & (bv)->bv_data[2]) ||                    \
  110.            ((vec)->bv_data[3] & (bv)->bv_data[3])                       \
  111. )
  112.  
  113. #  define bclr(vec)       { bzero((bitvec*)vec,sizeof(bitvec)); }
  114. #  define bset(vec)       bisv((bitvec*)vec,(bitvec*)&ones)
  115. #endif __BITVEC_H__
  116.